package com.作业.Day9;

import java.util.Scanner;

public class Homework3 {
    public static void main(String[] args) {
        System.out.print("请输入字符串");
        Scanner scanner = new Scanner(System.in);
        String inputs = scanner.next();
        System.out.println();
        System.out.print("请输入你要查找的字符");
        String word = scanner.next();
        int counter = counter(inputs, word);
        if(counter==0){
            System.out.println(inputs+"没包含"+word);
        }
        else
            System.out.println(inputs+"中包含"+counter+"个"+word);
    }
    public static int counter(String inputs,String word){
        String substring = inputs.substring(inputs.indexOf(word));
        int nums=0;
        for (int i = 0; i <substring.length() ; i++) {
            char c = substring.charAt(i);
            if(word.charAt(0)==c){
                 nums++;
            }
        }
        return nums;
    }
}
